<?php
class User_verification
{
	public $obj;
	public $is_login;
	public $user_info;
	public function __construct()
	{
		$this->obj =& get_instance();
		$this->is_login = $this->obj->input->cookie('is_login', TRUE);
	}
	public function is_login()
	{
		if($this->is_login == 0 || empty($this->is_login))
		{
			return 0;//没有登录
		}
		else
		{
			return 1;
		}
	}
	function is_user_name($postData)
	{
		$userInfo = $this->obj->User_model->getForUser($postData);
		if(empty($userInfo))
		{
			return 0; //用户名空
		}
		else
		{
			return 1;
		}
	}
	function is_verifica($postData)
	{
		$userInfo = $this->obj->User_model->getForUser($postData['user']);
		if(empty($userInfo))
		{
			return 0; //用户名错误
			exit;
		}
		$userInfo = $userInfo[0];
		$pwd = $this->obj->common_func->createPwd($postData['pwd']);
		$this->obj->input->set_cookie(array('name'=>'user_id','value'=>$userInfo['id'],'expire'=>10000000));
		return ($pwd == $userInfo['pwd'])?1:2; //1正确2失败
	}
	function is_tradecode($postData)
	{
		$userInfo = $this->obj->User_model->getForUser($postData['user']);
		if(empty($userInfo))
		{
			return 0; //用户名错误
			exit;
		}
		$userInfo = $userInfo[0];
		$tradecode = $this->obj->common_func->createTradecode($postData['tradecode']);
		return ($tradecode == $userInfo['tradecode'])?1:2; //1正确2失败
	}
}